home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / user / cup_viewteamprogress.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  15KB  |  432 lines

  1. /* Mode=Set */
  2. /* ***********************************************************************
  3.  
  4.    VIEW TEAM PROGRESS PROGRAM FOR FOOTBALL REXX SUITE
  5.   ----------------------------------------------------
  6.                    Copyright  Mark Naughton 1997
  7.  
  8.  
  9. Version    Date     History
  10. --------------------------------------------------------------------------
  11.  1.0       181297   First release.
  12.            140998   Added support for Two-Leg matches and Away Goals.
  13.            210499   Added check for no team specified.
  14.            250899   Added error msg to file checks.
  15.            110999   Converted to use locale. Some error messages, before
  16.                     reading the locale, will still be in English.
  17.  
  18. **************************************************************************
  19.  
  20. Procedure
  21. ---------
  22.  
  23. 1. Check files exist.
  24. 2. Read '.cf' file and get cup name and team list.
  25. 3. Search for selected team and give error if cannot find it, else set
  26.    marker.
  27. 4. Read '.scf' file and read in all round names and matches that the
  28.    selected team was in.
  29. 5. Display title.
  30. 6. Loop. Get roundname and change if replay. Get Home and Away type.
  31. 7. Read match and get opponent and score, adding it to goals conceeded
  32.    and goals scored.
  33. 8. Check next line for Extra Time, and append to score string. Change
  34.    goals_con/scored accordingly.
  35. 9. Check next line for Penalties, and append to score string.
  36. 10.Display round, home/away, opponent and score.
  37. 11.End loop.
  38. 12.Exit.
  39.  
  40. ************************************************************************** */
  41. PARSE ARG league_stuff
  42.  
  43. version      = 1
  44. input_file   = '.cf'
  45. input2_file  = '.scf'
  46. separator    = '*'
  47. matches.     = '???'
  48. mcount       = 0
  49. not_played   = '__   __'
  50. teams.       = '???'
  51. counter      = 0
  52. title        = '*CUP_TITLE='
  53. awaygs       = '*CUP_AWAYG='
  54.  
  55.  
  56. parse var league_stuff league_file search_team
  57. league_file = "Data/" || league_file
  58.  
  59. if open(datafile,"Data/Football.locale",'r') then do
  60.    line = readln(datafile)
  61.    locdir = strip(line)
  62.    close(datafile)
  63. end
  64. else do
  65.    say
  66.    say "ERROR :    (ViewTeamProgress)"
  67.    say
  68.    say "Cannot read 'Data/Football.locale' for the locale settings."
  69.    exit
  70. end
  71.  
  72. dcupdir = locdir"Football.locale_cup"
  73. locdir  = locdir"User/Cup_ViewTeamProgress.data"
  74.  
  75. if open(datafile,"ENV:FootballRXPath",'r') then do
  76.    line = readln(datafile)
  77.    rxdir = strip(line)
  78.    close(datafile)
  79. end
  80. else
  81.    rxdir = "SYS:Rexxc/"
  82.  
  83. if exists(locdir) > 0 then do
  84.   address command rxdir'rx 'locdir
  85.   VarCount = getclip('VarCount')
  86.   do i = 1 to VarCount
  87.     interpret getclip('var.'i)
  88.   end
  89. end
  90. else do
  91.    say
  92.    say "ERROR :    (ViewTeamProgress)"
  93.    say
  94.    say "Cannot find '"locdir"' to read locale settings."
  95.    exit
  96. end
  97.  
  98. if exists(dcupdir) > 0 then do
  99.   address command rxdir'rx 'dcupdir
  100.   VarCount = getclip('VarCount')
  101.   do i = 1 to VarCount
  102.     interpret getclip('var.'i)
  103.   end
  104. end
  105. else do
  106.    say
  107.    say "ERROR :    (ViewTeamProgress)"
  108.    say
  109.    say "Cannot find '"dcupdir"' to read cup locale settings."
  110.    exit
  111. end
  112.  
  113. if exists(league_file || input_file) = 0  then do
  114.    say
  115.    say cvtp_error
  116.    say
  117.    say cvtp_t1"'"league_file || input_file"'."
  118.    exit
  119. end
  120.  
  121. if exists(league_file || input2_file) = 0 then do
  122.    say
  123.    say cvtp_error
  124.    say
  125.    say cvtp_t1"'"league_file || input2_file"'."
  126.    exit
  127. end
  128.  
  129. if search_team = "" then do
  130.    say
  131.    say cvtp_error
  132.    say
  133.    say cvtp_t3
  134.    say
  135.    say cvtp_t4
  136.    say
  137.    exit
  138. end
  139.  
  140. if open(datafile,league_file || input_file,'r') then do
  141.    do while ~eof(datafile)
  142.       line = readln(datafile)
  143.       if pos(title,line) > 0 then        cupname= delstr(line,1,11)
  144.       if pos(awaygs,line) > 0 then       awayg  = delstr(line,1,11)
  145.       if pos(separator,line) = 0 then do
  146.          line = strip(line)
  147.          if counter = 0 then do
  148.             teams.1 = line
  149.             counter = 1
  150.          end
  151.          else do
  152.             counter       = counter + 1
  153.             teams.counter = line
  154.          end
  155.       end
  156.    end
  157.    close(datafile)
  158. end
  159. else do
  160.    say
  161.    say cvtp_error
  162.    say
  163.    say cvtp_t2"'"league_file||input_file"'"cvtp_t5
  164.    exit
  165. end
  166.  
  167. sel=-1
  168. search_team = strip(search_team)
  169. do i=1 to counter
  170.    if pos(search_team,teams.i) > 0 then
  171.       sel = i
  172. end
  173. if sel < 0 then do
  174.    say
  175.    say cvtp_error
  176.    say
  177.    say cvtp_t8" '"search_team"'"cvtp_t9
  178.    exit
  179. end
  180.  
  181. if open(datafile,league_file || input2_file,'r') then do
  182.    do while ~eof(datafile)
  183.       line = readln(datafile)
  184.       if pos("*Round",line) > 0 then do
  185.          mcount = mcount + 1
  186.          matches.mcount = line
  187.       end
  188.       if pos(separator,line) = 0 & pos("#",line) = 0 then do
  189.          line = strip(line)
  190.          if pos(teams.sel,line) > 0 then do
  191.             mcount = mcount + 1
  192.             matches.mcount = line
  193.             mkr = 1
  194.          end
  195.          else
  196.             mkr = 0
  197.       end
  198.       if pos("#",line) > 0 & mkr = 1 then do
  199.          mcount = mcount + 1
  200.          matches.mcount = line
  201.       end
  202.    end
  203.    close(datafile)
  204. end
  205. else do
  206.    say
  207.    say cvtp_error
  208.    say
  209.    say cvtp_t2"'"league_file||input2_file"'"cvtp_t5
  210.    exit
  211. end
  212.  
  213. say
  214. say center("'"cupname"'",78)
  215. say "-------------------------------------------------------------------------------"
  216. say
  217. say cvtp_t10" : "teams.sel
  218. say
  219. say
  220. say cvtp_t11
  221. say cvtp_t12
  222. say
  223. goals_con = 0
  224. goals_scr = 0
  225. donem = 0
  226.  
  227. do i=1 to mcount
  228.    if pos("*Round",matches.i) > 0 then do
  229.       if pos("Replay",matches.i) > 0 then
  230.          round = left(cs_t31,15,' ')
  231.       else do
  232.          parse var matches.i "*Round="name
  233.          round = substr(name,1,5)
  234.          if pos("1 Leg",name) > 0 then round = round" "cvtp_t14
  235.          if pos("2 Legs",name) > 0 then round = round" "cvtp_t15
  236.          round = left(round,15,' ')
  237.       end
  238.       donem = 0
  239.       h = 0
  240.       j = i + 1
  241.       if pos(teams.sel,matches.j) = 1 then do
  242.          round = round||cvtp_t16
  243.          h = 1
  244.          donem = 1
  245.       end
  246.       if pos(teams.sel,matches.j) > 1 then do
  247.          round = round||cvtp_t17
  248.          h = 2
  249.          donem = 1
  250.       end
  251.       if donem = 1 then do
  252.          if pos(not_played,matches.j) > 0 then do
  253.             if h = 1 then opponent = strip(substr(matches.j,41,30))
  254.             if h = 2 then opponent = strip(substr(matches.j,1,30))
  255.             say round""left(opponent,32)"     -  "cvtp_t18
  256.          end
  257.          else do
  258.             sd = ''
  259.             if pos("2 Legs",name) > 0 then do
  260.                for = strip(substr(matches.j,32,2))
  261.                aga = strip(substr(matches.j,37,2))
  262.                if h = 1 then do
  263.                   sd = right(for,2)""cvtp_t19""left(aga,2)
  264.                   goals_scr = goals_scr + for
  265.                   goals_con = goals_con + aga
  266.                   opponent = strip(substr(matches.j,41,30))
  267.                end
  268.                else do
  269.                   sd = right(aga,2)""cvtp_t19""left(for,2)
  270.                   goals_scr = goals_scr + aga
  271.                   goals_con = goals_con + for
  272.                   opponent = strip(substr(matches.j,1,30))
  273.                end
  274.                k = j + 1
  275.                if pos("#1st Leg",matches.k) > 0 then do
  276.                   parse var matches.k "#1st Leg" for1l aga1l .
  277.                   for1l = strip(for1l)
  278.                   aga1l = strip(aga1l)
  279.                   if h = 1 then
  280.                      sd = sd"  "cvtp_t20": "right(for1l+for,2)""cvtp_t19""left(aga1l+aga,2)
  281.                   else
  282.                      sd = sd"  "cvtp_t20": "right(aga1l+aga,2)""cvtp_t19""left(for1l+for,2)
  283.                   if (for1l+for) = (aga + aga1l) then do
  284.                      if pos("YES",awayg) > 0 then do
  285.                         if for1l > aga then do
  286.                            if h = 1 then
  287.                               extra_line = "                                                                 "strip(teams.sel)" "cvtp_t21
  288.                            else
  289.                               extra_line = "                                                                 "opponent" "cvtp_t21
  290.                            np = 1
  291.                         end
  292.                         if for1l < aga then do
  293.                            if h = 1 then
  294.                               extra_line = "                                                                 "opponent" "cvtp_t21
  295.                            else
  296.                               extra_line = "                                                                 "strip(teams.sel)" "cvtp_t21
  297.                            np = 1
  298.                         end
  299.                      end
  300.                   end
  301.                end
  302.                k = k + 1
  303.                if pos("#Score After Extra Time",matches.k) > 0 then do
  304.                   for1 = strip(substr(matches.k,32,2))
  305.                   aga1 = strip(substr(matches.k,37,2))
  306.                   if h = 1 then do
  307.                      sd = sd".  "cvtp_t22": "right(for1,2)""cvtp_t19""left(aga1,2)"   "cvtp_t20": "right(for1l+for1,2)""cvtp_t19""left(aga1l+aga1,2)
  308.                      goals_scr = goals_scr - for + for1
  309.                      goals_con = goals_con - aga + aga1
  310.                   end
  311.                   else do
  312.                      sd = sd".  "cvtp_t22": "right(aga1,2)""cvtp_t19""left(for1,2)"   "cvtp_t20": "right(aga1l+aga1,2)""cvtp_t19""left(for1l+for1,2)
  313.                      goals_scr = goals_scr - aga + aga1
  314.                      goals_con = goals_con - for + for1
  315.                   end
  316.                   if (for1+for1l) = (aga1 + aga1l) then do
  317.                      if pos("YES",awayg) > 0 then do
  318.                         if for1 > aga then do
  319.                            if h = 1 then
  320.                               extra_line = "                                                                 "strip(teams.sel)" "cvtp_t21
  321.                            else
  322.                               extra_line = "                                                                 "opponent" "cvtp_t21
  323.                            extra_line2= "                                                                 "cvtp_t23
  324.                            np = 2
  325.                         end
  326.                         if for1 < aga then do
  327.                            if h = 1 then
  328.                               extra_line = "                                                                 "opponent" "cvtp_t21
  329.                            else
  330.                               extra_line = "                                                                 "strip(teams.sel)" "cvtp_t21
  331.                            extra_line2= "                                                                 "cvtp_t23
  332.                            np = 2
  333.                         end
  334.                      end
  335.                   end
  336.                   k = k + 1
  337.                   if pos("#Penalties",matches.k) > 0 then do
  338.                      for1 = strip(substr(matches.k,32,2))
  339.                      aga1 = strip(substr(matches.k,37,2))
  340.                      sd = sd||","
  341.                      if h = 1 then
  342.                         extra_line3 = "                                                                 "cvtp_t24": "right(for1,2)""cvtp_t19""left(aga1,2)
  343.                      else
  344.                         extra_line3 = "                                                                 "cvtp_t24": "right(aga1,2)""cvtp_t19""left(for1,2)
  345.                      np = 3
  346.                   end
  347.                end
  348.                else do
  349.                   if pos("#Penalties",matches.k) > 0 then do
  350.                      for1 = strip(substr(matches.k,32,2))
  351.                      aga1 = strip(substr(matches.k,37,2))
  352.                      if h = 1 then
  353.                         sd = sd"  "cvtp_t24": "right(for1,2)""cvtp_t19""left(aga1,2)
  354.                      else
  355.                         sd = sd"  "cvtp_t24": "right(aga1,2)""cvtp_t19""left(for1,2)
  356.                   end
  357.                end
  358.             end
  359.             if pos("2 Legs",name) = 0 then do
  360.                for = strip(substr(matches.j,32,2))
  361.                aga = strip(substr(matches.j,37,2))
  362.                if h = 1 then do
  363.                   sd = right(for,2)""cvtp_t19""left(aga,2)
  364.                   goals_scr = goals_scr + for
  365.                   goals_con = goals_con + aga
  366.                   opponent = strip(substr(matches.j,41,30))
  367.                end
  368.                else do
  369.                   sd = right(aga,2)""cvtp_t19""left(for,2)
  370.                   goals_scr = goals_scr + aga
  371.                   goals_con = goals_con + for
  372.                   opponent = strip(substr(matches.j,1,30))
  373.                end
  374.                g = j + 1
  375.                if pos("#Score After Extra Time",matches.g) > 0 then do
  376.                   for1 = strip(substr(matches.g,32,2))
  377.                   aga1 = strip(substr(matches.g,37,2))
  378.                   if h = 1 then do
  379.                      sd = sd"  "cvtp_t22": "right(for1,2)""cvtp_t19""left(aga1,2)
  380.                      goals_scr = goals_scr - for + for1
  381.                      goals_con = goals_con - aga + aga1
  382.                   end
  383.                   else do
  384.                      sd = sd"  "cvtp_t22": "right(aga1,2)""cvtp_t19""left(for1,2)
  385.                      goals_scr = goals_scr - aga + aga1
  386.                      goals_con = goals_con - for + for1
  387.                   end
  388.                   g = g + 1
  389.                   if pos("#Penalties",matches.g) > 0 then do
  390.                      for1 = strip(substr(matches.g,32,2))
  391.                      aga1 = strip(substr(matches.g,37,2))
  392.                      if h = 1 then
  393.                         sd = sd"  "cvtp_t24": "right(for1,2)""cvtp_t19""left(aga1,2)
  394.                      else
  395.                         sd = sd"  "cvtp_t24": "right(aga1,2)""cvtp_t19""left(for1,2)
  396.                   end
  397.                end
  398.                else do
  399.                   if pos("#Penalties",matches.g) > 0 then do
  400.                      for1 = strip(substr(matches.g,32,2))
  401.                      aga1 = strip(substr(matches.g,37,2))
  402.                      if h = 1 then
  403.                         sd = sd"  "cvtp_t24": "right(for1,2)""cvtp_t19""left(aga1,2)
  404.                      else
  405.                         sd = sd"  "cvtp_t24": "right(aga1,2)""cvtp_t19""left(for1,2)
  406.                   end
  407.                end
  408.             end
  409.             say round""left(opponent,32)"   "sd
  410.             if np > 0 then do
  411.                if np = 3 then say extra_line3
  412.                if np = 1 | np = 2 then say extra_line
  413.                if np = 2 then say extra_line2
  414.                np = 0
  415.             end
  416.             donem = 0
  417.          end
  418.       end
  419.    end
  420. end
  421. say
  422. say
  423. say
  424. say left(cvtp_t25,20," ")": "goals_scr
  425. say left(cvtp_t26,20," ")": "goals_con
  426. say
  427. say
  428. say "-------------------------------------------------------------------------------"
  429.  
  430. exit
  431.  
  432. /*************************************************************************************/